package com.twt.recruit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.twt.recruit.entity.PrimeQuestions;
import com.twt.recruit.entity.Question;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface QuestionMapper extends BaseMapper<Question> {

    @Select("select question_id from question where group_id = #{groupId} and project_id = #{projectId}")
    List<Integer> questionIdsByProjectAndGroupId(Integer projectId, Integer groupId);

    @Delete("delete from question where project_id = #{projectId}")
    void delQuestionProjectId(Integer projectId);

    @Delete("delete from question_option where project_id = #{projectId}")
    void delQuestionOptionProjectId(Integer projectId);

    @Delete("delete from prime_questions where project_id = #{projectId}")
    void delPrimeQuestionByProjectId(Integer projectId);

    @Insert("insert into prime_questions (project_id, question) VALUES (#{projectId}, #{question})")
    void addPrimeQuestions(Integer projectId, String question);

    @Select("select question from prime_questions where project_id = #{projectId}")
    List<String> getPrimeQuestions(Integer projectId);
}
